﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using ExtBusiness;
using ExtBusiness.Interface;
using ExtBusiness.FlowOperation;


public partial class WebPubManager_SystemLogs : PageBase
{
    private WorkFlowPubSettting wfpsTemp = new WorkFlowPubSettting();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GridviewDatabind();
        }
    }

    #region 数据绑定
    /// <summary>
    /// Gridviews the databind.
    /// </summary>
    private void GridviewDatabind()
    {
        DataTable dtTemp = new DataTable();
        ViewState["flag"] = Request["flag"];
        if (ViewState["flag"] != null)
        {
            if (ViewState["flag"].ToString() == "InterfaceLog")
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "function", "<script>SetBackColor(1);</script>");//设置按钮样式
                dtTemp = wfpsTemp.GetInterfaceLogs("", txtdatebegin.Value, txtdateend.Value, ddlFlag.SelectedItem.Value);
                
                tdUserID.Visible = false;
                tdddlOptid.Visible = false;
                tdFlag.Visible = true;
                gridviewCar.Columns[3].Visible = false;
                gridviewCar.Columns[4].Visible = false;
                gridviewCar.Columns[6].Visible = false;
                gridviewCar.Columns[7].HeaderText = "调用类型";
                gridviewCar.Columns[8].Visible = false;
                gridviewCar.HideTextLength = 45;
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "function", "<script>SetBackColor(0);</script>");//设置按钮样式                
                dtTemp = wfpsTemp.GetSystemLogs("", txtUserID.Text.Trim(), txtdatebegin.Value, txtdateend.Value, ddlOptid.SelectedItem.Value);
                tdFlag.Visible = false;
            }
        }
        else
        {
            dtTemp = wfpsTemp.GetSystemLogs("", txtUserID.Text.Trim(), txtdatebegin.Value, txtdateend.Value, ddlOptid.SelectedItem.Value);
            tdFlag.Visible = false;
        }
        gridviewCar.DataSource = dtTemp;
        gridviewCar.RecordCount = dtTemp.Rows.Count;
        gridviewCar.DataBind();
    }
    #endregion

    /// <summary>
    /// datagrid数据加载
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void recvgrid_OnLoadData(object sender, EventArgs e)
    {
        this.GridviewDatabind();
    }

    #region 行创建
    /// <summary>
    /// Handles the RowCreated event of the gridviewCar control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewRowEventArgs"/> instance containing the event data.</param>
    protected void gridviewCar_RowCreated(object sender, GridViewRowEventArgs e)
    {
        switch (e.Row.RowType)
        {
            case DataControlRowType.DataRow:
                //保留此删除与恢复的方法 add by zhongjian 20091223
                DataRowView drv = e.Row.DataItem as DataRowView;
                if (drv == null)
                {
                    break;
                }
                HyperLink hyDel = e.Row.FindControl("hydel") as HyperLink;
                if (hyDel != null)
                {
                    hyDel.Attributes.Add("OnClick", "return confirm('确定要删除该业务吗？')");
                    hyDel.NavigateUrl = "SerialStateManager.aspx?action=delete&flag=Remove&iid=" + drv["iid"];
                }
                //查看详情
                HyperLink hyMessage = e.Row.FindControl("hyMessage") as HyperLink;
                if (hyMessage != null)
                {
                    hyMessage.NavigateUrl = "SystemlogDetails.aspx?flag=" + ViewState["flag"] + "&id=" + drv["id"];
                }
                break;
        }
    }
    #endregion

    /// <summary>
    /// 查询
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnQuery_Click(object sender, EventArgs e)
    {
        GridviewDatabind();
    }

}

